/**
 * Boost Logging library
 *
 * Author: John Torjo, www.torjo.com
 *
 * Copyright (C) 2007 John Torjo (see www.torjo.com for email)
 *
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or copy at
 *      http://www.boost.org/LICENSE_1_0.txt)
 *
 * See http://www.boost.org for updates, documentation, and revision history.
 * See http://www.torjo.com/log2/ for more details
 */

#include "logger.hpp"

// Step 6: Define the filters and loggers you'll use
BOOST_DEFINE_LOG(g_l, log_type)
BOOST_DEFINE_LOG_FILTER(g_l_filter, boost::logging::level::holder)

void initLogger(std::string logFile, bool isCout) {
	boost::filesystem::path::default_name_check( boost::filesystem::no_check);

    // Add formatters and destinations
    // That is, how the message is to be formatted...
    g_l()->writer().add_formatter(boost::logging::formatter::time(" [$hh:$mm.$ss] "));
    g_l()->writer().add_formatter(boost::logging::formatter::idx());
    g_l()->writer().add_formatter(boost::logging::formatter::append_newline());

    //        ... and where should it be written to
	if (isCout) 
	{	
		g_l()->writer().add_destination(boost::logging::destination::cout());
    }
	g_l()->writer().add_destination(boost::logging::destination::dbg_window());
    g_l()->writer().add_destination(boost::logging::destination::file(logFile));
    g_l()->turn_cache_off();
}
